using BCW.GameTypes.SkyBlock;
using UnityEngine;

public class TDMscore : MonoBehaviour
{
	public UILabel myTamScoreLabel;

	public UILabel enemyTeamScoreLabel;

	public GameObject counters;

	public GameObject bars;

	public UISprite aliesFill;

	public UILabel aliesBlocks;

	public UISprite enemyFill;

	public GameObject leaderboardIcon;

	public bool endRound;

	private void Start()
	{
		if (!(aliesFill != null) || !(enemyFill != null) || !(bars != null) || !(counters != null))
		{
			return;
		}
		switch (GameController.instance.curTypeGame)
		{
		case TypeGame.SkyBlock:
			bars.SetActive(true);
			counters.SetActive(true);
			aliesFill.fillAmount = 0f;
			enemyFill.fillAmount = 0f;
			break;
		case TypeGame.CopsAndRobbers:
			bars.SetActive(false);
			counters.SetActive(false);
			if (leaderboardIcon != null)
			{
				leaderboardIcon.SetActive(false);
			}
			break;
		case TypeGame.race:
			bars.SetActive(false);
			counters.SetActive(false);
			break;
		default:
			counters.SetActive(true);
			bars.SetActive(false);
			break;
		}
	}

	public void UpdateScores()
	{
		if (PhotonNetwork.room == null)
		{
			return;
		}
		switch (GameController.instance.curTypeGame)
		{
		case TypeGame.TDM:
		case TypeGame.WalkingRobots:
			if (BCWFlagController.instance != null)
			{
				if (TDMController.myTeam == PunTeams.Team.red)
				{
					myTamScoreLabel.text = BCWFlagController.instance.countRedTeam.ToString();
					enemyTeamScoreLabel.text = BCWFlagController.instance.countBlueTeam.ToString();
				}
				else
				{
					myTamScoreLabel.text = BCWFlagController.instance.countBlueTeam.ToString();
					enemyTeamScoreLabel.text = BCWFlagController.instance.countRedTeam.ToString();
				}
			}
			break;
		case TypeGame.tanks:
			if (PhotonNetwork.room.customProperties.ContainsKey(TDMController.myTeam.ToString()))
			{
				myTamScoreLabel.text = ((int)PhotonNetwork.room.customProperties[TDMController.myTeam.ToString()]).ToString();
			}
			else
			{
				myTamScoreLabel.text = "0";
			}
			if (PhotonNetwork.room.customProperties.ContainsKey(TDMController.enemyTeam.ToString()))
			{
				enemyTeamScoreLabel.text = ((int)PhotonNetwork.room.customProperties[TDMController.enemyTeam.ToString()]).ToString();
			}
			else
			{
				enemyTeamScoreLabel.text = "0";
			}
			break;
		case TypeGame.Zombe:
			myTamScoreLabel.text = TDMController.instance.CountTeam(TDMController.myTeam).ToString();
			enemyTeamScoreLabel.text = TDMController.instance.CountTeam(TDMController.enemyTeam).ToString();
			break;
		case TypeGame.SkyBlock:
			if ((!endRound || TDMController.instance.pvpStarted) && SkyBlockController.instance != null && TDMController.myTeam != 0)
			{
				if (aliesFill != null && enemyFill != null)
				{
					aliesFill.fillAmount = SkyBlockController.instance.GetScore(TDMController.myTeam);
					enemyFill.fillAmount = SkyBlockController.instance.GetScore(TDMController.enemyTeam);
				}
				myTamScoreLabel.text = SkyBlockController.instance.GetCountBlocks(TDMController.myTeam).ToString();
				enemyTeamScoreLabel.text = SkyBlockController.instance.GetCountBlocks(TDMController.enemyTeam).ToString();
			}
			break;
		case TypeGame.RocketLeague:
			if (PhotonNetwork.room.customProperties.ContainsKey(TDMController.myTeam.ToString()))
			{
				myTamScoreLabel.text = ((int)PhotonNetwork.room.customProperties[TDMController.myTeam.ToString()]).ToString();
			}
			else
			{
				myTamScoreLabel.text = "0";
			}
			if (PhotonNetwork.room.customProperties.ContainsKey(TDMController.enemyTeam.ToString()))
			{
				enemyTeamScoreLabel.text = ((int)PhotonNetwork.room.customProperties[TDMController.enemyTeam.ToString()]).ToString();
			}
			else
			{
				enemyTeamScoreLabel.text = "0";
			}
			break;
		case TypeGame.Pixelmon:
			if (PhotonNetwork.room.customProperties.ContainsKey(TDMController.myTeam.ToString()))
			{
				myTamScoreLabel.text = ((int)PhotonNetwork.room.customProperties[TDMController.myTeam.ToString()]).ToString();
			}
			else
			{
				myTamScoreLabel.text = "0";
			}
			if (PhotonNetwork.room.customProperties.ContainsKey(TDMController.enemyTeam.ToString()))
			{
				enemyTeamScoreLabel.text = ((int)PhotonNetwork.room.customProperties[TDMController.enemyTeam.ToString()]).ToString();
			}
			else
			{
				enemyTeamScoreLabel.text = "0";
			}
			break;
		case TypeGame.Lobby:
		case TypeGame.OnlineSandbox:
		case TypeGame.Offline:
		case TypeGame.Unknown:
		case TypeGame.CopsAndRobbers:
			break;
		}
	}
}
